<template>
  <div class="header" >
      <van-nav-bar
        :title="title"
        :left-text='commonHeaderInfo.leftText'
        :right-text="commonHeaderInfo.rightText"
        :left-arrow="commonHeaderInfo.leftArrow"
        @click-left="onClickLeft"
        @click-right="onClickRight">
             <template #right>
<!--                <img class="logOutImg" src="../assets/img/index/001.png" alt="">-->
                 <span class="logOutImg">安全退出</span>
                <!-- <van-icon name="search" size="18" /> -->
            </template>
        </van-nav-bar>
  </div>
</template>

<script>
export default {
    data(){
        return{

        }

    },
    props:{
        title:{
            type:String,
            default:'内蒙古自治区能源大数据平台'
        },
        commonHeaderInfo:{
           type: Object,
           default:()=>{
               return{
                   leftText:'',
                   rightText:'',
                   leftArrow:true
               }
           }
        }
    },
    methods:{
        // 返回上一级
        onClickLeft(){
            this.$router.go(-1)
        },
        //
        onClickRight(){
            this.$dialog.alert({
                message: '确定退出？',
                showCancelButton:true,

            }).then(()=>{
                this.$axios.get(`http://58.18.173.195:8082/mengenergy-background/LogoutController/logout`,JSON).then((data) => {
                    if (data.code == 0) {
                        localStorage.removeItem('token')
                        localStorage.removeItem('menuIds')
                        localStorage.removeItem('regionName')
                        localStorage.removeItem('time')
                        console.log('注销成功');
                        this.$router.push('/login')
                    } else if (data.code == 1) {
                        console.log('注销失败');
                    }
                })
            });
        }
    }
}
</script>

<style lang="scss" scoped>
.logOutImg{
    width: 0.6rem;
   line-height: 1;
   font-size: 12px;
}

</style>>
<style>
    .van-nav-bar__left{
        top: 30%;
    }
.header .van-nav-bar{
    height: 1.3rem;
    background-color:#E5F1FF;

}
.header .van-nav-bar__title{
    padding-top:0.4rem;
}
.header .van-nav-bar__right{
         top:0.4rem;
    }
</style>

